from flask import Blueprint, jsonify
from flask_jwt_extended import jwt_required
from app.utils.decorators import handle_errors

videos_bp = Blueprint('videos', __name__, url_prefix='/api/videos')


@videos_bp.route('', methods=['GET'])
@jwt_required()
@handle_errors
def get_video_list():
    """获取视频教程列表"""
    # 模拟视频数据，实际项目中应该从数据库获取
    video_list = [
        {
            "id": 1,
            "title": "设备连接教程",
            "duration": "3:25",
            "poster": "https://example.com/images/video1-thumb.jpg",
            "url": "https://example.com/video1.mp4",
            "description": "本视频详细介绍了如何连接治疗设备，包括设备开机、蓝牙配对、小程序连接等步骤。"
        },
        {
            "id": 2,
            "title": "参数设置指南",
            "duration": "5:12",
            "poster": "https://example.com/images/video2-thumb.jpg",
            "url": "https://example.com/video2.mp4",
            "description": "本视频演示了如何在小程序中设置治疗参数，包括电流强度、治疗时间、刺激模式等选项的配置方法。"
        },
        {
            "id": 3,
            "title": "安全使用须知",
            "duration": "4:08",
            "poster": "https://example.com/images/video3-thumb.jpg",
            "url": "https://example.com/video3.mp4",
            "description": "本视频介绍了使用治疗设备时的安全注意事项，包括使用前检查、使用中监测、使用后维护等重要信息。"
        }
    ]
    
    return jsonify({
        'videos': video_list,
        'total': len(video_list)
    })